package com.htrq.service;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.htrq.dao.ICKgsDao;
import com.htrq.entity.ICKgs;
import com.htrq.entity.Page;

@Service
@Transactional(value = "txManager2")
public class ICardgsService {
	@Resource
	private ICKgsDao gsDao;

	public List<ICKgs> getAllgs(ICKgs gs, Page page) throws ParseException {
		// TODO Auto-generated method stub
		List<Object[]> list = gsDao.getAllgs(gs, page);
		List<ICKgs> kgs = new ArrayList<ICKgs>();
		for (Object[] obj : list) {
			ICKgs g = new ICKgs();
			g.setAutoId(obj[0].toString());
			g.setCardNumber(obj[1].toString());
			g.setGstate(obj[2].toString());
			g.setCuser(obj[3].toString());
			g.setGsDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(obj[4].toString()));
			g.setNodeName(obj[5].toString());
			kgs.add(g);
		}
		return kgs;
	}
	public Long getTotal(ICKgs gs) {
		// TODO Auto-generated method stub
		return gsDao.getTotal(gs);
	}
	public List<Object[]> exportbyForm(ICKgs gs) {
		// TODO Auto-generated method stub
		List<Object[]> list = gsDao.exportbyForm(gs);
		for (Object[] obj : list) {
			if(Integer.parseInt(obj[4].toString())==1){
				obj[4]="挂失";
			}else if(Integer.parseInt(obj[4].toString())==0){
				obj[4]="取消挂失";
			}else{
				obj[4]="未指定";
			}
		}
		return list;
	}
}
